{template "header.html"}

<form class="form-horizontal" method="post" role="form" id="myform" style="margin-top:-20px;">
    {$form}
    <div class="portlet  light " style="padding: 0">
        {if $list.unused}
        <div class="portlet-title tabbable-line">
            <ul class="nav nav-tabs" style="float:left;">
                <li class=" {if $pp==0}active{/if}">
                    <a href="{$tab_url}&pp=0"> {dr_lang('未使用的附件')} </a>
                </li>
                <li class="dev {if $pp==1}active{/if}">
                    <a href="{$tab_url}&pp=1"> {dr_lang('已使用的附件')} </a>
                </li>
            </ul>
        </div>
        {else}
        <?php $pp=1;?>
        {/if}
        <div class="portlet-body">

                {if $pp==0}
                    <div role="presentation" class="table table-fc-upload table-striped clearfix">
                        <div class="files">
                            {table table=attachment_unused where=$list.unused IN_fileext=$fileext order=id_desc pagefile=admin page=1 pagesize=$psize urlrule=$urlrule}
                            <div class="template-download yl_files_row files_row {if $i==0}border_none{/if}">
                                <label class="mt-table mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                    <input type="checkbox" class="checkboxes" name="ids0[]" value="{$t.id}" />
                                    <span></span>
                                </label>
                                <label class="files_row_preview preview">{dr_file_list_preview_html($t)}</label>
                                <label class="label label-sm label-success hidden-xs" style="margin-right: 10px;"> {dr_format_file_size($t.filesize)} </label>
                                <label class="label label-sm label-default" title="{$t.filename}">{dr_strcut($t.filename, 10)}</label>
                                <label><button onclick="dr_file_delete(this, '{$t.id}')" type="button" class="btn red file_delete btn-xs"><i class="fa fa-trash"></i></button></label>
                            </div>
                            {/table}
                        </div>
                    </div>
                {elseif $pp==1}
                    <div class="row  margin-bottom-20 template-download">
                            <div class="col-md-12 text-center margin-bottom-20">
                                <label><select  id="dr_field_name"class="form-control">
                                    {loop $sfield $i $t}
                                    <option value="{$i}" {if $param.name == $i} selected{/if}>{$t}</option>
                                    {/loop}
                                </select></label>
                                <label>
                                    <input type="text" class="form-control" value="{$param.value}" id="dr_field_value">
                                </label>
                                <label><a class="btn green btn-sm onloading" href="javascript:;" onclick="dr_fsearch()"> <i class="fa fa-search"></i> {dr_lang('搜索')}</a></label>
                            </div>
                    </div>
                    <div role="presentation" class="table table-fc-upload table-striped clearfix">

                        <div class="files">
                            {table table=attachment_data where=$list.used IN_fileext=$fileext order=id_desc pagefile=admin page=1 pagesize=$psize urlrule=$urlrule}
                            {php $url = dr_get_file_url($t, 50, 50);}
                            <div class="template-download yl_files_row files_row">
                                <label class="mt-table mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                    <input type="checkbox" class="checkboxes" name="ids1[]" value="{$t.id}" />
                                    <span></span>
                                </label>
                                <label class="files_row_preview preview">{dr_file_list_preview_html($t)}</label>
                                <label class="label label-sm label-success" style="margin-right: 10px;"> {dr_format_file_size($t.filesize)} </label>
                                <label class="label label-sm label-default" title="{$t.filename}">{dr_strcut($t.filename, 10)}</label>
                            </div>
                            {/table}
                        </div>
                    </div>
                {/if}

            <div class="row  margin-top-20 ">
                <div class="col-md-12 text-center margin-bottom-20">

                    {$pages}
                </div>
            </div>

        </div>
    </div>


    <input type="hidden" name="is_ajax" value="1">
    <input type="hidden" name="is_page" id="dr_page" value="{$pp}">
</form>

<script>
    function dr_fsearch() {
        var url = '{$search_url}&name='+$('#dr_field_name').val()+'&value='+$('#dr_field_value').val();
        window.location.href = url;
    }
</script>

{template "footer.html"}